package com.lql.lqlreader.setting

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.widget.Toast
import com.lql.lqlreader.BaseActivity
import com.lql.lqlreader.LoginSuccessEvent
import com.lql.lqlreader.R
import kotlinx.android.synthetic.main.activity_settings.*
import org.greenrobot.eventbus.EventBus

class SettingActivity : BaseActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_settings)
        setLeftTitleAndDisplayHomeAsUp("设置")

        tv_login_out.setOnClickListener {
            val loginPreference = getSharedPreferences("loginInfo", MODE_PRIVATE)
            loginPreference.edit().putString("loginUser", null).apply()
            Toast.makeText(this, "已退出登录", Toast.LENGTH_SHORT).show()
            finish()
            EventBus.getDefault().post(LoginSuccessEvent())
        }
    }
}